<?php
namespace Admin\Controller;
use Admin\Controller\BaseController;

/**
 * 公共设置
 * Class CommonSetController
 * @package Admin\Controller
 */
class CommonSetController extends BaseController {
	/**
	 * 构造函数
	 */
	public function __construct() {
		//无需进行权限检测的功能
		\Org\Auth\AuthUtil::setNoAuthFuncList([]);
		parent::__construct();
	}

    /**
     * 列表
     */
	public function commonSetList() {
        $resList = D('CommonSet','Logic')->getAllCommonSetList([]);
		$this->assign('resList', $resList);

		$this->loadFrame('commonSetList');
	}
	/**
     * 编辑信息
     */
	public function editCommonSet(){
        $id = I('get.id');
        if(!$id){
            header('Location:/admin/CommonSet/CommonSetList');
            exit();
        }
        $resInfo = D('CommonSet','Logic')->getCommonSetInfo(['id'=>$id]);

        $this->assign('resInfo',$resInfo);
        $this->loadFrame('editCommonSet');
    }

    /**
     * 保存
     * @return string
     */
    public function ajaxSaveCommonSet(){
	    $id = I('post.id');
	    $title = I('post.title');
	    $data = I('post.data');
	    $status = I('post.status');
	    if(!$id){
	       return Response(201,"参数异常");
        }
        $play_data = [];
	    $play_data['id'] = $id;
	    $title && $play_data['title'] = $title;
	    $data && $play_data['data'] = $data;
	    $status && $play_data['status'] = $status;

	    D('CommonSet','Logic')->saveCommonSet($play_data);
    }
}